// Load the original lockfile if it exists.
if let Ok(orig) = paths::read(dst) {
+ if has_crlf_line_endings(&orig) {
+ out = out.replace("\n", "\r\n");
+ }
if out == orig {
// The lockfile contents haven't changed so don't rewrite it.
// This is helpful on read-only filesystems.
Ok(())
}
+fn has_crlf_line_endings(s: &str) -> bool {
+ // Only check the first line.
+ if let Some(lf) = s.find('\n') {
+ s[..lf].ends_with('\r')
+ } else {
+ false
+ }
+}
+
fn emit_package(dep: &toml::Table, out: &mut String) {
out.push_str(&format!("name = {}\n", lookup(dep, "name")));
out.push_str(&format!("version = {}\n", lookup(dep, "version")));